﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class D04_Mathf1 : MonoBehaviour
{
    private void OnGUI()
    {
        if (GUILayout.Button("-1的绝对值"))
        {
            print(Mathf.Abs(-1F));
        }
        if (GUILayout.Button("判断浮点数相等要用Abs,不能用=="))
        {
            float f1 = 1.1234567f;
            float f2 = 1.1234568f;

            if (Mathf.Abs(f1 - f2) < 0.001)
            {
                print("相等");
            }
        }
        if (GUILayout.Button("最大值"))
        {
            print(Mathf.Max(new int[] { 2, 1, 3, 9, 0 }));
        }

        if (GUILayout.Button("3PI弧度是多少度?"))
        {
            print(Mathf.PI * 3 * Mathf.Rad2Deg);
        }
        if (GUILayout.Button("540度是多少弧度?"))
        {
            print(540 * Mathf.Deg2Rad);
        }

        if (GUILayout.Button("Sin(30度)?"))
        {
            print(Mathf.Sin(30 * Mathf.Deg2Rad));
        }
        if (GUILayout.Button("5.5和6.5的四舍五入    x.5都返回偶数"))
        {
            Debug.LogFormat("5.5:{0}  6.5:{1}", Mathf.Round(5.5f), Mathf.Round(6.5f));
        }
        if (GUILayout.Button("3的三次方"))
        {
            print(Mathf.Pow(3, 3));
        }
    }
}